elements_aray = []

for input_crc in range(4):
    a = str(raw_input())
    k = a.split(",")
    for i in range(len(k)):
        k[i] = int(k[i])

    elements_aray.append(k)


def test(x,y):

        firstList = []

        count = 0

        for element in range(x):
            secondList = []

            for element2 in range(y):
                count += 1
                secondList.append(count)
            firstList.append(secondList)


        print firstList

for j in elements_aray:
    test(*j)
